home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2011 May / PC Advisor 190 E.iso / pc / ESSENTIALS / VLC Media Player 1.1 / vlc-1.1.5-win32.exe / lua / playlist / metachannels.lua < prev    next >
Encoding:
Text File  |  2010-11-13  |  2.0 KB  |  60 lines

  1. --[[
  2.  $Id$
  3.  
  4.  Copyright ┬⌐ 2010 VideoLAN and AUTHORS
  5.  
  6.  Authors: R├⌐mi Duraffort <ivoire at videolan dot org>
  7.  
  8.  This program is free software; you can redistribute it and/or modify
  9.  it under the terms of the GNU General Public License as published by
  10.  the Free Software Foundation; either version 2 of the License, or
  11.  (at your option) any later version.
  12.  
  13.  This program is distributed in the hope that it will be useful,
  14.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  GNU General Public License for more details.
  17.  
  18.  You should have received a copy of the GNU General Public License
  19.  along with this program; if not, write to the Free Software
  20.  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  21. --]]
  22.  
  23. require "simplexml"
  24.  
  25. function probe()
  26.     return vlc.access == 'http' and string.match( vlc.path, 'metachannels.com' )
  27. end
  28.  
  29. function parse()
  30.     local webpage = ''
  31.     local options
  32.  
  33.     while true do
  34.         local line = vlc.readline()
  35.         if line == nil then break end
  36.         webpage = webpage .. line
  37.     end
  38.  
  39.     local feed = simplexml.parse_string( webpage )
  40.     local channel = feed.children[1]
  41.  
  42.     -- list all children that are items
  43.     local tracks = {}
  44.     for _,item in ipairs( channel.children ) do
  45.         if( item.name == 'item' ) then
  46.             simplexml.add_name_maps( item )
  47.             local url = string.gsub( item.children_map['link'][1].children[1], '&', '&' )
  48.             if( string.match( url, '%.m4v' ) ) then options = { ':play-and-pause', ':demux=avformat,ffmpeg' }
  49.                                                else options = { ':play-and-pause' } end
  50.             table.insert( tracks, { path = url,
  51.                                     title = item.children_map['title'][1].children[1],
  52.                                     arturl = item.children_map['media:thumbnail'][1].attributes['url'],
  53.                                     options = options } )
  54.         end
  55.     end
  56.  
  57.     return tracks
  58. end
  59.  
  60.